package com.aqie.arithmetic.comparableData;

public class MyDate implements Comparable<MyDate> {
    private final int day;
    private final int month;
    private final int year;

    public MyDate(int day, int month, int year) {
        this.day = day;
        this.month = month;
        this.year = year;
    }

    public int getDay() {
        return day;
    }

    public int getMonth() {
        return month;
    }

    public int getYear() {
        return year;
    }

    @Override
    public int compareTo(MyDate o) {
        if (this.year > o.year) return +1;
        if (this.year < o.year) return -1;
        if (this.month > o.month) return +1;
        if (this.month < o.month) return -1;
        return Integer.compare(this.day, o.day);
    }

    @Override
    public String toString() {
        return "MyDate{" +
                "day=" + day +
                ", month=" + month +
                ", year=" + year +
                '}';
    }
}
